<link href='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/css/ui.jqgrid.css' rel='stylesheet' type='text/css'>
<script type='text/javascript' src='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/js/jquery.jqGrid.min.js'></script>
<script type='text/javascript' src='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/js/i18n/grid.locale-<?=strtolower($this->config->item('lang_obj')->key)?>.js'></script> 
<div class="my-account form-container">
	<div class="col-left sidebar">
		<div class="block block-account">
			<div class="block-title">
				<strong>
					<span><?=lang('my_account')?></span>
				</strong>
			</div>
			<div class="block-content">
				<ul>
					<li class="current">
						<strong>
							<?=lang('my_dashbord')?>
						</strong>					
					</li>
					<li>
						<a href="<?=site_url('user/my_account/')?>">
							<?=lang('account_info')?>
						</a>
					</li>
					<li>
						<a href="<?=site_url('user/my_address/')?>">
							<?=lang('my_address')?>
						</a>					
					</li>
					<li >
						<a href="<?=site_url('user/address_book')?>">
						<?=lang('address_book')?>
						</a>	
					</li>
					<li>
						<a href="<?=site_url('user/my_orders/')?>">
							<?=lang('my_orders')?>
						</a>
					</li>
					<li >
						<a href="<?=site_url('user/newsLetter')?>">
						<?=lang('newsletter')?>
						</a>	
					</li>
					<li class="last">
						<a href="<?=site_url('user/logout/')?>">
							<?=lang('logout')?>
						</a>
					</li>
				</ul>
			</div>
			
		</div>
		<div class="block block-account">
			<div class="block-title">
				<strong>
					<span><?=lang('my_orders')?></span>
				</strong>
			</div>
			<div class="block-content">
				
				<ul>
					<li >
						<span><?=lang('last_order_items')?></span>
						<br />
						<form id="myorder_form_12" name="myorder_form" method ="post" action='<?=base_url()?>cart/cart_a'>
							<?php
							$i = 0;
							 foreach ($prod_array as $prod){?>
								<input type="checkbox" class="my_order_checkbox" id="prod_<?=$i?>" name='P_<?=$i?>' value='<?php echo $prod['id'].'_'. $prod['size']; ?>' />
								<?php  echo $prod['name']; ?>
							<br />
							<?php $i++; }?>
							<input type="hidden" id="counter" value=<?=$i?>>
						</form>
					</li>
					<li>
						<div id="search_price_btn1" class="right"><?=lang('add_to_cart')?></div>
						<div class="clear"></div>
					</li>
				</ul>
			
			</div>
		</div>
	</div>
	<div class="col-main">
		<div class="lpadding10">
			<h1 style = "margin:10px 0"><?=lang('my_address')?></h1>
			<span>
				<strong><?=lang('hello_text')?>,  <?=$user_name?>!</strong>
			</span> <br />
			<p>
				<?=lang('dashboard_welcomme_text')?>
			</p>
	
			<h2><?=lang('recent_orders_text')?></h2>
		</div>
		
		<div class="lpadding10">
			<table id="grid1"  ></table>
			<div id="pgrid1"></div> 
		</div>
		<h2 class=" lpadding10 "><?=lang('account_information')?></h2>
	
		<div style="width:390px" class=" lpadding10 left">
			<div class="block block-account" style="border: 0">
				<div class="block-title">
				<?=lang('contact_informations')?> <div class="right"><a href="<?=site_url('user/my_account/')?>"><?=lang('edit')?></a></div>
				</div>
				<?php echo $user_name; ?><br/>
				<?php echo $user_email; ?><br>
				<a href="<?=site_url('user/my_account/')?>"><?=lang('change_password')?></a>
			</div>
			
			
		</div>
		<div style="width:390px" class="lpadding10 left">
			<div class="block block-account" style="border: 0">
				<div class="block-title">
				<?=lang('newsletters')?> <div class="right"><a href="<?=site_url('user/newsLetter/')?>"><?=lang('edit')?></a></div>
				</div>
				<?php echo ($user_newsletter)? lang('you_are_currently_subscribed') :lang('you_are_currently_not_subscribed') ; ?><br/>
			</div>	
			
		</div>
		<div class="clear"></div>
		<div style="width:790px" class="lpadding10 left">
			<div class="block block-account" style="border: 0">
				<div class="block-title">
				<?=lang('address_book')?> <div class="right"><a href="<?=site_url('user/address_book')?>"><?=lang('manenge_address_book')?></a></div>
				</div>
				<div class="left" style="width:390px">
				<br>
				<br>
				<?php if (!empty($address_billing_default)){?>
					<strong><?=lang("default_billing_address") ?></strong><br/>
					<?=$address_billing_default->first_name ." " .$address_billing_default->last_name?><br/>
					<?=$address_billing_default->address .", " .$address_billing_default->city?><br/>
					<?=$address_billing_default->state_provide .", " .$address_billing_default->country_name?><br/>
					<?=$address_billing_default->postcode ?><br/>
					T:<?=$address_billing_default->postcode .", " .$address_billing_default->tel_number?><br/>
					<a href="<?=site_url('user/add_new_address/'.$address_billing_default->id)?>"><?=lang('change_billing_address')?></a>
					<br>
					<br>
				<?php }?>
				</div>
				<div class="left" style="width:390px">
				<br>
				<br>
				<?php if (!empty($address_shipping_default)){?>
					<strong><?=lang("default_shipping_address") ?></strong><br/>
					<?=$address_shipping_default->first_name ." " .$address_shipping_default->last_name?><br/>
					<?=$address_shipping_default->address .", " .$address_shipping_default->city?><br/>
					<?=$address_shipping_default->state_provide .", " .$address_shipping_default->country_name?><br/>
					<?=$address_shipping_default->postcode ?><br/>
					T:<?=$address_shipping_default->postcode .", " .$address_shipping_default->tel_number?><br/>
					<a href="<?=site_url('user/add_new_address/'.$address_shipping_default->id)?>"><?=lang('change_shipping_address')?></a>
				<?php }?>				
				</div>
			</div>	
			
		</div>
	</div>
	<div class="clear"></div>

</div>

<script type="text/javascript">


function addOrderComment(){
	var data=new Object();
	counter = $('#counter').val();
	for( i= 0; i<counter; i++){
		var  name= "prod_"+i;
		data.name = $('#prod_'+i).val();
	}
	console.log(data);
	$.ajax({
		url: $( "#myorder_form" ).attr('action'),
		type: 'get',
		data: data,
		success: function(data){
				
		},
		complete: function() {
		}
	});					
}
$(document).ready(function() {
	$("#search_price_btn1").click(function(){
		counter = $('#counter').val();
		data = '';
		for( i= 0; i<counter; i++){
			if ($('#prod_'+i).is(":checked")){
				data += $('#prod_'+i).val()+ "#";
			}
		}
		if (data==''){
			alert('[please_select_one_product]');
		}else{
			window.location = settings.base_url + lang.lang_key + '/cart/cart_a/'+data
		}
		
	});
	
	jQuery("#grid1").jqGrid({
	    datatype: "local",
	    height: 'auto',
	    width: '790',
	    url: '<?=site_url('user/jqgrid_show/')?>',
	    datatype: "json",
	    colNames: [
			'<?=lang('order_id')?>',
	    	'<?=lang('date')?>',
	    	'<?=lang('shipping_info')?>',
	    	'<?=lang('status')?>', 
	    	'<?=lang('acction')?>'
	    	],
	    colModel: [
	       {name: 'id', index: 'id',width: 50, align:'center',fixed:true}, 
	       {name: 'data_add',index: 'data_add',width: 70,fixed:true},
	       {name: 'shipping_info',index: 'shipping_info',width:240,fixed:true},
	       {name: 'status',index: 'status',width: 100,fixed:true},
	       {name: 'acction',index: 'acction',width:320,fixed:true}
	    ],
	    rowNum:5, 
	    sortname: 'id',
	    sortorder: 'desc',
	    viewrecords: true,
	    
	    caption: false,
	    pager: '#pgrid1'
	    
	});
	jQuery("#grid1").jqGrid('navGrid','#pgrid1',{edit:false,add:false,del:false,search:false});
	
});

</script>
